﻿/************************************************************************

 This file is part of "10 Second Tim".

 "10 Second Tim" is free software: you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
 the Free Software Foundation, either version 3 of the License, or
 (at your option) any later version.

 "10 Second Tim" is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.

 You should have received a copy of the GNU General Public License
 along with "10 Second Tim".  If not, see <http://www.gnu.org/licenses/>.

************************************************************************/

// All code (c)2013 Scott Bevin. all rights reserved

using System;
using System.IO;
using System.Xml.Serialization;
using Microsoft.Xna.Framework;

namespace LDE
{
	public class SavedSettings
	{
		public bool SfxOn;
		public bool MSAAOn;
		public bool FullScreen;

		public SavedSettings( )
		{
			SfxOn = true;
			MSAAOn = true;
			FullScreen = false;
		}
	}

	public class SavedSettingsHelper
	{
		public SavedSettings Settings = new SavedSettings( );

		public void Load( )
		{
#if !SILVERLIGHT
			try
			{
				Stream stream = TitleContainer.OpenStream( "Settings.xml" );
				TextReader file = new StreamReader( stream );
				Settings = (SavedSettings)new XmlSerializer( typeof( SavedSettings ) ).Deserialize( file );
				stream.Close( );
			}
			catch
			{
			}
#endif
		}

		public void Save( )
		{
#if !SILVERLIGHT
			try
			{
				FileStream file = new FileStream( "Settings.xml", FileMode.OpenOrCreate );
				new XmlSerializer( typeof( SavedSettings ) ).Serialize( file, Settings );
				file.Close( );
			}
			catch
			{
			}
#endif
		}
	}
}